package wrapper

import "SQLWrapperForGO/common"

/**
 * description：
 * <p>
 * </p>
 * change history:
 * date                      defect#    person       comments
 * -------------------------------------------------------------<p>
 * 2023/9/28 09:12          ********    kong.ruo    create file.
 *
 * @author kong.ruo
 * @date 2023/9/28 09:12
 *
 * @since go 1.20
 */

type BasicWrapper struct {
	tableName string
	queries   []map[string]*OperationMode
}

type Condition interface {
	SetTable(table string) *BasicWrapper
	Eq(column string, value interface{}) *BasicWrapper
	In(column string, values interface{}) *BasicWrapper
	// Fetch Build Wrapper to exec sql
	Fetch()
}

type Wrapper interface {
	Build() string
}

func NewBasicWrapper() *BasicWrapper {
	return &BasicWrapper{queries: make([]map[string]*OperationMode, 0)}
}

func (bc *BasicWrapper) SetTable(tableName string) *BasicWrapper {
	bc.tableName = tableName
	return bc
}

func (bc *BasicWrapper) Eq(column string, value interface{}) *BasicWrapper {
	query := make(map[string]*OperationMode)
	query[column] = getNewMode(common.Eq, value)
	bc.queries = append(bc.queries, query)
	return bc
}

func (bc *BasicWrapper) In(column string, values interface{}) *BasicWrapper {
	query := make(map[string]*OperationMode)
	query[column] = getNewMode(common.In, values)
	bc.queries = append(bc.queries, query)
	return bc
}

func (bc *BasicWrapper) Fetch() {

}
